package com.example.kuaizu.controller;

import com.example.kuaizu.service.InFileUploadService;
import com.example.kuaizu.utils.AjaxResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: wangmx15
 * @date: 2025/10/2
 **/

@Log4j2
@RestController
@RequestMapping("/fileUploadController")
@RequiredArgsConstructor
public class FileUploadController {
    final InFileUploadService fileUploadService;

    /**
     * 图片上传
     */
    @RequestMapping("/uploadImg")
    public AjaxResponse uploadImg(MultipartFile file) {
        return AjaxResponse.success("上传成功", fileUploadService.uploadImg(file));
    }

    /**
     * 查看所有上传的图片
     */
    @RequestMapping("/querImgList")
    public AjaxResponse querImgList() {
        return AjaxResponse.success("查询成功", fileUploadService.querImgList());
    }

    /**
     * 查看所有上传的图片
     */
    @RequestMapping("/deletImg")
    public AjaxResponse deletimg(String name) {
        fileUploadService.deletimg(name);
        return AjaxResponse.success("删除成功");
    }

}
